# Author:Zhang Yu

import socket
import os
server = socket.socket()
server.bind(('127.0.0.1',6969))
server.listen(5) # 监听 最多5个链接
while True:
    conn,addr = server.accept() # 等待进来
    while True:
        data = conn.recv(1024)
        if not data:
            print("没有请求, 将被断开")
            break
        print("recv:",data.decode())
        res = os.popen(data.decode()).read()
        conn.send(res.encode("utf-8"))
server.close()